package org.example.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

/**
 * @Author：ygp
 * @Package：org.example.config
 * @Project：ResApi
 * @name：ResourcesConfig
 * @Date：2023/12/21 10:15
 * @Filename：ResourcesConfig
 */

@Configuration
public class ResourcesConfig implements WebMvcConfigurer {

    @Value("${ftp.host.file}")
    public String basedir;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        /** 通过url访问项目外的目录图片*/
        registry.addResourceHandler("/**").addResourceLocations("file:"+basedir+ File.separator);
    }

}
